package com.lhkj.ct.meta.modules.common.validation;

import com.lhkj.ct.base.validator.group.ValGroups;
import com.lhkj.ct.meta.modules.patient.model.dto.ImportPatientDto;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * TODO 菜单级联校验
 */
public class PatientGroupSequenceProvider implements DefaultGroupSequenceProvider<ImportPatientDto> {

    @Override
    public List<Class<?>> getValidationGroups(ImportPatientDto patientDto) {
        List<Class<?>> defaultGroupSequence = new ArrayList<>();
        // warn 这一步不能省,否则Default分组都不会执行，会抛错
        defaultGroupSequence.add(ImportPatientDto.class);
        if (patientDto != null) {
            if (Objects.equals(2, patientDto.getAccountPolicy())){
                defaultGroupSequence.add(ValGroups.Insert.class);
            }
        }
        return defaultGroupSequence;
    }
}
